<?php
/**
 * Created by PhpStorm.
 * User: zhangrxiang
 * Date: 2017/6/26
 * Time: 21:19
 */
$file = file(__FILE__);
foreach ( $file as $item ) {
	file_put_contents("tmp.txt",$item,FILE_APPEND);
}

//1.php
echo basename(__FILE__).PHP_EOL;
//sudoers
echo "1) ".basename("/etc/sudoers.d", ".d").PHP_EOL;
//passwd
echo "2) ".basename("/etc/passwd").PHP_EOL;
//etc
echo "3) ".basename("/etc/").PHP_EOL;
//.
echo "4) ".basename(".").PHP_EOL;
//
echo "5) ".basename("/").PHP_EOL;

//E:\PHPSRC\git-src\PHPTEST\2017\06\26
echo dirname(__FILE__).PHP_EOL;

function mb_basename($file)
{
	$a = explode(DIRECTORY_SEPARATOR,$file);
	return end($a);
}
//1.php
echo mb_basename(__FILE__);

copy(__FILE__,'2.php');